using System.Collections;
using UnityEngine;

public class Arrow1 : MonoBehaviour
{
	private Transform tf;

	private Rigidbody2D rb;

	private AttackInfo SCRT_AttackInfo;

	private void Awake()
	{
		tf = GetComponent<Transform>();
		rb = GetComponent<Rigidbody2D>();
		SCRT_AttackInfo = GetComponent<AttackInfo>();
	}

	public void Init(float[] data)
	{
		base.gameObject.layer = (int)data[2];
		rb.angularVelocity = 0f;
		tf.rotation = Quaternion.Euler(Vector2.zero);
		tf.localScale = new Vector2(data[0], 1f);
		rb.velocity = new Vector2((0f - data[0]) * 60f, 0f);
		SCRT_AttackInfo.kindOfWeapon = 5;
		SCRT_AttackInfo.power = (int)data[1];
		SCRT_AttackInfo.force = new Vector2(rb.velocity.x * 0.3f, rb.velocity.y);
		DeActive();
	}

	private void OnTriggerEnter2D(Collider2D collision)
	{
		if (collision.CompareTag("Player") || collision.CompareTag("Enemy"))
		{
			StopAllCoroutines();
			base.gameObject.SetActive(false);
		}
	}

	public void DeActive()
	{
		StartCoroutine(IE_DeActive());
	}

	private IEnumerator IE_DeActive()
	{
		yield return new WaitForSeconds(5f);
		base.gameObject.SetActive(false);
	}
}
